//    Copyright (C) Kherty.  All rights reserved.

using System;
using System.Windows;
using System.Windows.Input;
using OpenLS.Chart.UI.Internals;
using OpenLS.Drawing;

namespace OpenLS.Chart.UI
{
    partial class CategoryAxisResources
    {
        public CategoryAxisResources()
        {
            InitializeComponent();
        }
        private void onFormatAxis(object sender, ExecutedRoutedEventArgs e)
        {
            var a = (Axis)e.Parameter;
            PropertyHelper.ShowPropertiesFor(a, sender as FrameworkElement, ChartCommands.FormatAxis.Text, PropertyTabHint.None);
            e.Handled = true;
        }
        private void onDeleteAxis(object sender, ExecutedRoutedEventArgs e)
        {
            var a = (Axis)e.Parameter;
            a.Delete = true;
            e.Handled = true;
        }
        

        private void onMouseDown(object sender, MouseButtonEventArgs e)
        {
            ((IInputElement)sender).Focus();
            e.Handled = true;
        }

        private void onCanAddTitle(object sender, CanExecuteRoutedEventArgs e)
        {
            var axis = (Axis) e.Parameter;
            e.CanExecute = axis.Title == null || axis.Title.Text == null || axis.Title.Text.Content == null;
            e.Handled = true;
        }

        private void onAddTitle(object sender, ExecutedRoutedEventArgs e)
        {
            var axis = (Axis) e.Parameter;
            axis.Title = new Title(new TextBody(UIStringTable.DefaultTitle));
            e.Handled = true;
        }

        private void onDeleteTitle(object sender, ExecutedRoutedEventArgs e)
        {
            var axis = AxisElement.GetAxis((DependencyObject) sender);
            axis.Title = null;
            e.Handled = true;
        }
    }
}
